package com.superb.common.utils;

import com.superb.common.core.exception.SuperbException;
import lombok.extern.slf4j.Slf4j;

/**
 * @author sking
 * @version 1.0.0.0
 * @Title 当前服务是否生效
 * @date 2022/8/17 21:17
 */
@Slf4j
public class NacosServerUtils {
    private static boolean enable = false;

    public static void isThrowException() {
        if (!enable) {
            throw new SuperbException("当前服务已下线");
        }
    }

    public static boolean isEnable() {
        return enable;
    }

    public static void setEnable(boolean enable) {
        log.info("当前服务是否生效:" + enable);
        NacosServerUtils.enable = enable;
    }
}
